#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

typedef pair<int, int> PII;

bool myComp(PII lhs, PII rhs)
{
    return lhs.first == rhs.first ? lhs.second < rhs.second : lhs.first < rhs.second;
}


int findLongestSeq(vector<PII> &arr)
{
    vector<int> dp(arr.size(), 1);
    vector<int> last(arr.size(), -1);
    
    for (int i = 1; i < arr.size(); i++) {
	for (int j = 0; j < i; j++) {
	    cout << arr[j].second << " " << arr[i].second << endl;
	    if (arr[j].second < arr[i].second && dp[i] < dp[j]+1) {
		dp[i] = dp[j]+1;
		last[i] = j;
	    }
	}
    }
    cout << dp[dp.size()-1] << endl;

    for (int i = 0; i < last.size(); i++) 
	cout << dp[i] << " ";
    cout << endl;

    for (int i = 0; i < last.size(); i++) 
	cout << last[i] << " ";
    cout << endl;

    int cur = last[last.size()-1];
    do  {
	cout << arr[cur].first << " " << arr[cur].second << endl;
	cur = last[cur];
    } while(cur != -1);

    cout << endl;
}


int main(int argc, char **argv)
{
    vector<PII> arr;
    arr.push_back(PII(65, 100));
    arr.push_back(PII(90, 150));
    arr.push_back(PII(50, 120));
    arr.push_back(PII(56, 90));
    arr.push_back(PII(75, 190));
    arr.push_back(PII(60, 95));
    arr.push_back(PII(68, 110));
    arr.push_back(PII(80, 92));
    sort(arr.begin(), arr.end());
    findLongestSeq(arr);
    for (int i = 0; i < arr.size(); i++)
	cout << arr[i].first << " " << arr[i].second << endl;
}



